/*
 * @Description:
 * @version:
 * @Author: sunqian_sr
 * @Date: 2022-11-17 17:01:45
 * @LastEditors: Andy
 * @LastEditTime: 2023-03-15 15:04:24
 */
import { resolve } from 'path'
import { defineConfig } from 'vite'
import { svgBuilder } from 'vite-svg-icon'
import { useBasic, useBuild, useCss, usePlugins, useServer } from '../../base.vite.config'
import { EnumProxy } from '../../globalEnum.js'

const pathSrc = resolve(__dirname)
const appName = 'main'
export default defineConfig(({ mode }) => ({
  ...useBasic(mode, pathSrc),
  resolve: {
    alias: [
      {
        find: '@',
        replacement: resolve(__dirname, 'src')
      }
    ]
  },
  server: {
    ...useServer({
      target: EnumProxy.DEV,
      hmr: true
    })
  },
  css: {
    preprocessorOptions: {
      ...useCss()
    }
  },
  plugins: [...usePlugins(pathSrc, mode), svgBuilder('./src/common/assets/svg/')],
  build: {
    ...useBuild(mode, pathSrc, appName)
  }
}))
